using imitateMacQQ.WebApi.Domain.Request.utils;
using imitateMacQQ.WebApi.Domain.Token.wand.Token.Entity;
using imitateMacQQ.WebApi.Domain.Token.wand.Token.Interface;
using imitateMacQQ.WebApi.Domain.Token.wand.Token.letter;
using imitateMacQQ.WebApi.Domain.Token.wand.utils;

namespace imitateMacQQ.WebApi.Domain.Token.wand.Token.Service;

public class ApplyForTokenAgain : IGetAccessTokenUsedRefreshToken
{
    private JwtHelper JwtHelper { get; set; }

    public ApplyForTokenAgain(JwtHelper jwtHelper)
    {
        JwtHelper = jwtHelper;
    }

    public Request<LoginRefreshToken> GetAccessTokenUsedRefreshToken(LetterRefreshToken dto)
    {
        LoginRefreshToken loginRefreshToken = new LoginRefreshToken();
        if (string.IsNullOrEmpty(dto.Account))
            return Request<LoginRefreshToken>.Ok(loginRefreshToken);
        loginRefreshToken.AccessToken = JwtHelper.CreateToken(dto.Account ?? "COMEBACK");
        return Request<LoginRefreshToken>.Ok(loginRefreshToken);
    }
}